import { createRouter, createWebHistory } from "vue-router";
import current from './current'
import current2 from './current2'
import { qiankunRouter } from './qiankun'
export const menuList = [
    ...current,
    ...current2,
    ...qiankunRouter()
]
const routes = [
    {
        path: '/login',
        component: () => import('@/views/login/index.vue')
    },
    {
        path: "/",
        component: () => import('@/views/home/index.vue'),
        children: menuList
    },
    {
        path: '/:path(.*)*',
        name: 'PageNotFound',
        component: import('@/views/home/index.vue'),
        meta: {
            title: 'ErrorPage',
            hasAside: true
        }
    },
    // {
    //   path: '/:path(.*)*',
    //   name: 'PageNotFound',
    //   component: ExceptionPage,
    //   meta: {
    //     title: 'ErrorPage',
    //     hasAside: true
    //   }
    // }
]
// 创建路由
const router = createRouter({
    history: createWebHistory(),
    routes: routes
})
// 路由拦截 /:page*
router.beforeEach((to, from, next) => {
    // console.log('to', to)
    // console.log('from', from)
    // if (to.path === '/login') return next();
    // const token = window.sessionStorage.getItem('token')
    // if (!token) return next('/login')
    next()
})
export default router